import requests
import os
import time

import json
tkl = "ww(MHtY1lMScdy)ee"
header = {'User-Agent':"android micromessenger"}



with open("utils/data.txt") as f:
    ret = f.read()
# print(ret)
retValue = eval(ret)
# print(retValue)
acount = 0
content=""
for items in retValue:
    # print(items)
    p = items['name']
    for item in items["city"]:
        # print(item)
        for area in item['area']:
            if not '其他' in area:
                test = area.replace(" " ,"").replace("区" ,"").replace("市" ,"").replace("县" ,"")
                if len(test)>1:
#                    print(test)
                    content=content+"python3 readConfig.py meituantemplate.ini "+test+" 养生 1 1 1 1 1\n"
                    acount+=1
#                    print(acount)

print(content)
exit(1)

for a in aa:
    print(a)


def getTkl(tkl ):

    if "$" in tkl:
        tkl = tkl.split("$")[1]
    if "￥" in tkl:
        tkl = tkl.split("￥")[1]
    if "(" in tkl:
        tkl = tkl.split("(")[1]
        tkl = tkl.split(')')[0]
        print(tkl)

    url = 'http://www.maomaoyouxuan.com/rbt/tkl/a.php?tpwd=' + tkl
    try:
        r = requests.get(url)
        ret = r.text.split("tpwd=1")[1]
        tpwd = json.loads(ret)
        ret = tpwd['data']['tpwd']
    except:
        print("error happend")
    ret = ret.replace("￥", "")
    print(ret)
    return ret



print(getTkl(tkl))


print(os.getcwd())
oked = False
currentSize =0
maxSize = 0
while 1:

    time.sleep(2)
    if os.path.exists('a.txt'):
        print("sleep 30 for test file a.txt size change or not")
        time.sleep(3)
        print(str(os.path.getsize('a.txt')))
        maxSize = currentSize
        currentSize = os.path.getsize('a.txt')
        if maxSize == currentSize and not maxSize == 0 :
            break
    else:
        print("no a .txt")
print("game over")

    #
    # print(str(os.path.getsize("a.txt")))
